<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="混音档案,">










<meta name="description" content="混响的基本作用是制造距离感和空间感，在现代商业音乐中它也为乐曲增添不少魅力。然而不恰当的混响决策将会降低作品的水准。同时，由于混响效果对原始素材带来的改变极大，导致我们会在使用时格外谨慎，却也因此得不到真正「气派」的效果。过量地使用则可能会使你精心调整出来的混音变得一塌糊涂。 长话短说，下边是 10 条混音基本经验和技巧，希望能够帮助你越过混音中的陷阱，使混音工作更加得心应手。 1、长混响、短混响">
<meta name="keywords" content="混音档案">
<meta property="og:type" content="article">
<meta property="og:title" content="10 条混响技巧让你的混音更进一步">
<meta property="og:url" content="https://songjianzaina.gitee.io/10-条混响技巧让你的混音更进一步.html">
<meta property="og:site_name" content="有瓣教育 – 分享有用知识">
<meta property="og:description" content="混响的基本作用是制造距离感和空间感，在现代商业音乐中它也为乐曲增添不少魅力。然而不恰当的混响决策将会降低作品的水准。同时，由于混响效果对原始素材带来的改变极大，导致我们会在使用时格外谨慎，却也因此得不到真正「气派」的效果。过量地使用则可能会使你精心调整出来的混音变得一塌糊涂。 长话短说，下边是 10 条混音基本经验和技巧，希望能够帮助你越过混音中的陷阱，使混音工作更加得心应手。 1、长混响、短混响">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2020-01-06T01:52:04.347Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="10 条混响技巧让你的混音更进一步">
<meta name="twitter:description" content="混响的基本作用是制造距离感和空间感，在现代商业音乐中它也为乐曲增添不少魅力。然而不恰当的混响决策将会降低作品的水准。同时，由于混响效果对原始素材带来的改变极大，导致我们会在使用时格外谨慎，却也因此得不到真正「气派」的效果。过量地使用则可能会使你精心调整出来的混音变得一塌糊涂。 长话短说，下边是 10 条混音基本经验和技巧，希望能够帮助你越过混音中的陷阱，使混音工作更加得心应手。 1、长混响、短混响">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/booya/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":true,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>
<!--谷歌广告验证代码-->
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({
          google_ad_client: "ca-pub-2626449904708114",
          enable_page_level_ads: true
     });
</script>
<!--谷歌广告验证代码-->



  <link rel="canonical" href="https://songjianzaina.gitee.io/10-条混响技巧让你的混音更进一步.html">





  <title>10 条混响技巧让你的混音更进一步 | 有瓣教育 – 分享有用知识</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/booya/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">有瓣教育 – 分享有用知识</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">有瓣知识 – 有伴你我</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="http://www.newban.cn/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://songjianzaina.gitee.io">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="有瓣">
      <meta itemprop="description" content>
      <meta itemprop="image" content="images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="有瓣教育 – 分享有用知识">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">10 条混响技巧让你的混音更进一步</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-11-13T10:56:53+08:00">
                2019-11-13
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>混响的基本作用是制造距离感和空间感，在现代商业音乐中它也为乐曲增添不少魅力。然而不恰当的混响决策将会降低作品的水准。同时，由于混响效果对原始素材带来的改变极大，导致我们会在使用时格外谨慎，却也因此得不到真正「气派」的效果。过量地使用则可能会使你精心调整出来的混音变得一塌糊涂。</p>
<p>长话短说，下边是 10 条混音基本经验和技巧，希望能够帮助你越过混音中的陷阱，使混音工作更加得心应手。</p>
<h5 id="1、长混响、短混响"><a href="#1、长混响、短混响" class="headerlink" title="1、长混响、短混响"></a>1、长混响、短混响</h5><p>总体而言，在元素较拥挤的混音中建议使用短混响，舒缓的音乐中使用较长的混响。在使用混响效果器插件时不要按照预设值的字面意思去理解：比如把「大厅和房屋」视为长混响，「小房间」视为短混响，而是按照听觉效果来选择。如果你需要较短的混响，那么「大厅」效果中尾音时间较短的预设值也能满足你。选择的标准是尾音的特性，较长的尾音会掩盖声音的使其失去一定的临场感，较短的尾音则可以让声音更吸引听者的注意力。</p>
<h5 id="2、早期反射"><a href="#2、早期反射" class="headerlink" title="2、早期反射"></a>2、早期反射</h5><p>早期反射（Pre-delay）是多数混响效果器中的重要参数之一，早期反射可以让干声在混响出现之前先到达听者的耳朵，这意味着听者更易理解声音的内容。在混音人声时，早期反射能够清晰地保留字音的起音部分。从这个角度看来，它和压缩器有异曲同工之妙，对压缩设置一个较慢的起音值（attack），或对混响设置较多的早期反射，人声传达出的信息将更易理解。早期反射的时间在 20 毫秒至 80 毫秒之间较为常见，更长的设置将制造一种「交替出声」的感觉，偶尔会有需要这种效果的场合，但多数情况下并不合适。</p>
<h5 id="3、3D-混响"><a href="#3、3D-混响" class="headerlink" title="3、3D 混响"></a>3、3D 混响</h5><p>要获得更加广阔、丰富的空间感，你可以尝试重叠使用多个混响效果。比如说，叠加使用 3 个混响效果器，得到的空间感将十分真实。首先你可以选择一个小房间的混响效果预设，干声周围将出现一些小空间。接下来用上一个金属板混响（plate），干声所在的空间将进一步降低清晰度。最后添加一个尾音十分长的大厅混响，提升空间的上限，要注意别太过量。怎么知道有没有过量呢，请记住下面的话：</p>
<blockquote>
<p>成功的混响应该能提升你所追求的情绪；混响不仅增加空间，也会帮助你突出音乐的主题情绪。</p>
</blockquote>
<h5 id="4、用多少？"><a href="#4、用多少？" class="headerlink" title="4、用多少？"></a>4、用多少？</h5><p>混响的量完全取决于你的口味。如果在你的编曲中，混响是一个主要特色，那么就放手去大量使用。反之，只需要将声部、元素等粘合在一起即可，只要听上去有真实空间感就行。记住，只要有了混响，听起来就会大不一样。在做混响前，先独奏要处理的音轨。然后提升混响量，只要你听见混响效果即可。然后往下衰减一点点，直到你感觉似乎还想再加上一些的时候，停！这里大概就是正确的位置。</p>
<h5 id="5、高通滤波"><a href="#5、高通滤波" class="headerlink" title="5、高通滤波"></a>5、高通滤波</h5><p>或许你已经了解高通、低通滤波器的作用，并且已经知道怎么用它们保留低频的隆隆声或其他吸引人的频率。这个用法同样适用于混响，例如用高通滤波器去处理混响声，可以保持空间的开阔感。与之相反，如果把混响声的低频全部保留，随着挂载混响的轨道数增多，声音的清晰度将大大降低。</p>
<h5 id="6、用混响提升亮度"><a href="#6、用混响提升亮度" class="headerlink" title="6、用混响提升亮度"></a>6、用混响提升亮度</h5><p>当你尝试调整人声 EQ 却发现怎么也无法提升明亮感时，不妨试一试混响。在找到最具特色的 EQ 范围后，用混响来加强这个频段即可。当然，这个方法不仅限于处理人声。比如说，人声往往在 3K 的位置最具有表现力，所以我们先添加一个混响效果，在它后面挂载一个 EQ 效果器，衰减 3K 左右范围两边的频段，就能增加一些空气感和通透感。</p>
<h5 id="7、混响与冲击力"><a href="#7、混响与冲击力" class="headerlink" title="7、混响与冲击力"></a>7、混响与冲击力</h5><p>在处理军鼓时，往混响后面添加一个门限（Gate），效果会非常棒。将混响的早期反射设为 0.5 秒左右（即 500ms），并添加门限，得到突然切断的效果。这样做虽然会有不自然的因素，但可以制造出类似打碎玻璃的感觉。应用的比例合适，且粘合得自然，将增加军鼓的气势，而无需叠加「躯干（body）」声。在 Phil Collins 和 David Bowie 的作品中曾大量使用这种手法，使得它们的音乐别具一格。虽然历史久远，但现在依然有许多前沿制作人在使用它。</p>
<h5 id="8、为混响编组"><a href="#8、为混响编组" class="headerlink" title="8、为混响编组"></a>8、为混响编组</h5><p>为了测试你的混响效果，尤其在混响效果器数量较多的情况下，可以将它们编组，以便快速独奏、或将它们静音。这也就是进行 A/B 测试。你可以根据听到的效果迅速掌握当前的混响量，并决定是否还要继续增加。若把所有混响指定用一个推子来控制，你就能精确掌握总体混响的量，甚至按照第 5、6 条在混响上使用 EQ 处理。</p>
<blockquote>
<p>我们通常把混响视为立体声效果，然而单声道混响同样效果卓越。</p>
</blockquote>
<h5 id="9、Spring-混响和其他「脏声」"><a href="#9、Spring-混响和其他「脏声」" class="headerlink" title="9、Spring 混响和其他「脏声」"></a>9、Spring 混响和其他「脏声」</h5><p>某些乐器天生比较适合混响，有些则不是。我们通常喜欢把电吉他表现得十分突出，但常规的混响会柔化它们的冲击感。Spring（弹簧）混响等低保真处理在这里就很合适。它们的粗糙感恰恰为声音增添了躯体和表现力。另外，现在也十分流行用低保真混响来处理人声，以获得一些复古的感觉。</p>
<h5 id="10、单声道混响"><a href="#10、单声道混响" class="headerlink" title="10、单声道混响"></a>10、单声道混响</h5><p>我们通常把混响视为立体声效果，然而单声道混响同样效果卓越。如果你想突出某个乐器，让它站到「聚光灯」下，单声道混响是一个很棒的选择，你无需为此而改变整个混音编排。比如，要让听众注意到靠右边的键盘独奏，你可以添加一个单声道混响处理器，并将其声相调整到和键盘相衬的位置即可，这样能够获得不少的动态。</p>
<p>混响效果历经超过半个世纪的来来去去，现在我们似乎又处在重新发现混响的时代。今天的混响已经非常具有音乐性，十分精致，我们需要它，但也不能泛滥使用。混响效果在现代人声轨和音效当中大量出现，而鼓组却强调自然、突出且肌理丰富。请牢记：成功的混响应该能提升你所追求的情绪；混响不仅增加空间，也会帮助你突出音乐的主题情绪。</p>
<p><strong>本帖附件</strong></p>
<p><a href="https://u21519047.pipipan.com/fs/21519047-395416051" target="_blank" rel="noopener">点击下载</a></p>
<p><em>有瓣音频 – 有伴你我,更多编曲混音技术尽在有瓣音频</em></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="tags/混音档案/" rel="tag"># 混音档案</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="自制简易录音间，随时随地录出好声音.html" rel="next" title="自制简易录音间，随时随地录出好声音">
                <i class="fa fa-chevron-left"></i> 自制简易录音间，随时随地录出好声音
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="Cubase常用快捷键介绍.html" rel="prev" title="Cubase常用快捷键介绍">
                Cubase常用快捷键介绍 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


    <!-- newban文章内嵌广告 -->
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-2626449904708114" data-ad-slot="4238589764"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>

    <div class="post-spread">
      
    </div>
  </div>
  <!-- newban信息流广告 -->
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="-6t+ed+2i-1n-4w" data-ad-client="ca-pub-2626449904708114" data-ad-slot="6790755005"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">有瓣</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">45</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            

            
              
              
              <div class="site-state-item site-state-tags">
                
                  <span class="site-state-item-count">17</span>
                  <span class="site-state-item-name">标签</span>
                
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-5"><a class="nav-link" href="#1、长混响、短混响"><span class="nav-number">1.</span> <span class="nav-text">1、长混响、短混响</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#2、早期反射"><span class="nav-number">2.</span> <span class="nav-text">2、早期反射</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#3、3D-混响"><span class="nav-number">3.</span> <span class="nav-text">3、3D 混响</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#4、用多少？"><span class="nav-number">4.</span> <span class="nav-text">4、用多少？</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#5、高通滤波"><span class="nav-number">5.</span> <span class="nav-text">5、高通滤波</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#6、用混响提升亮度"><span class="nav-number">6.</span> <span class="nav-text">6、用混响提升亮度</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#7、混响与冲击力"><span class="nav-number">7.</span> <span class="nav-text">7、混响与冲击力</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#8、为混响编组"><span class="nav-number">8.</span> <span class="nav-text">8、为混响编组</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#9、Spring-混响和其他「脏声」"><span class="nav-number">9.</span> <span class="nav-text">9、Spring 混响和其他「脏声」</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#10、单声道混响"><span class="nav-number">10.</span> <span class="nav-text">10、单声道混响</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">有瓣</span>
  <div>
  <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
  <span id="busuanzi_container_site_pv">本站总访问量<span id="busuanzi_value_site_pv"></span>次</span>
  </div>
  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
          <span id="scrollpercent"><span>0</span>%</span>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/booya/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  

  

  
  

  

  

  

</body>
</html>
